home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / wtitle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  1.2 KB  |  59 lines

  1. /*
  2. ** wtitle.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "pictor.h"
  11.  
  12.  
  13. struct {
  14.     char left;
  15.     char right;
  16.     char top;
  17. } border[2] = {
  18.     { '\xB5','\xC6','\xCD' },
  19.     { '\xB4','\xC3','\xC4' },
  20. };
  21.  
  22. /*
  23. ** Prints a title at the top of the active window pane.
  24. */
  25. void wtitle(char *buffer)
  26. {
  27.     int i,len,btype;
  28.  
  29.     if(_PL_winhead == NULL)
  30.         return;
  31.  
  32.     vcolor(_PL_winhead->color);
  33.     btype = (_CURR_WPANE.top == _PL_winhead->top) ? 0 : 1;
  34.  
  35.     /* clear any existing title */
  36.     setvpos(_CURR_WPANE.top,_CURR_WPANE.left + 1);
  37.     vrepc(border[btype].top,getwcols());
  38.  
  39.     /* print new title if one was specified */
  40.     if(buffer != NULL) {
  41.         if(strlen(buffer) < (unsigned)(getwcols() - 4))
  42.             len = (strlen(buffer) + 4);
  43.         else
  44.             len = getwcols();
  45.         setvpos(_CURR_WPANE.top,_CURR_WPANE.left + center(len,getwcols()));
  46.         for(i = 0;i < len;i++) {
  47.             if(i == 0)
  48.                 vputc(border[btype].left);
  49.             else if(i == (len - 1))
  50.                 vputc(border[btype].right);
  51.             else if(i == 1 || i == (len - 2))
  52.                 vputc(' ');
  53.             else
  54.                 vputc(buffer[i - 2]);
  55.         }
  56.     }
  57.  
  58. } /* wtitle */
  59.